﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using LeagueOfRila.Model;
using LeagueOfRila;

namespace LeagueOfRila.View
{
    public class MenuConnectionView : BaseView
    {
        Texture2D backgroundImage;
        public bool error = false; 

        public MenuConnectionModel GetModel()
        {
            return this.model as MenuConnectionModel;
        }

        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            base.LoadContent();
            this.backgroundImage = Content.Load<Texture2D>("MenuConnectionView/backgroundConnection");

            //musique de fond
            //Client.music = Content.Load<SoundEffect>("Sounds/soundmenu");
            //Client.musicInstance = Client.music.CreateInstance();
            Client.backgroundSong = Content.Load<Song>("Sounds/soundmenu");
            Client.PlayMusic(Client.backgroundSong, true);
            
            //sons clavier
            Client.keysound = Content.Load<SoundEffect>("Sounds/keysound");
            Client.entersound = Content.Load<SoundEffect>("Sounds/entersound");

        }

        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {

            //encart pseudo
            this.DrawBackgroundImage(backgroundImage);
            this.DrawFont(this.GetModel().player.pseudo, new Vector2(73, 324), Color.Black);

            if (error)
            {
                //this.DrawRectangle(new Rectangle(28, 346, 321, 29), Color.White);
                this.DrawFont("Pseudo non disponible!", new Vector2(70, 230), Color.Red);
            }

            base.Draw(gameTime);
        }
    }
}
